package com.gosophia.conference.action.scheme;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.commons.web.logAnnotation.LogRecord;
import com.gosophia.conferenceManagement.scheme.dto.SchemeJobDataDTO;
import com.gosophia.conferenceManagement.scheme.ws.ConferenceSchemeWebService;
import com.opensymphony.xwork2.ActionContext;

/**
 * 
 * @author nana
 *
 */
@SuppressWarnings("serial")
@Scope("prototype")
@Controller("EditSchemeJobDataAction")
public class EditSchemeJobDataAction extends BaseSupportAction{

	private SchemeJobDataDTO schemeJobDataDTO;
	
	private String autoSaveDocument;
	
	@Autowired
	private ConferenceSchemeWebService conferenceSchemeWebService;
	
	@Override
	@LogRecord(eventAction="会议管理-修改会议方案",eventTarget="schemeJobDataDTO")
	public String _execute() throws Exception {
		if(schemeJobDataDTO.getOnlineDocumentDTO().getDocumentId() == null){
			schemeJobDataDTO = conferenceSchemeWebService.addShemeJobData(schemeJobDataDTO);
		} else {
			schemeJobDataDTO = conferenceSchemeWebService.updateSchemeJobData(schemeJobDataDTO);
		}
		if("no".equals(autoSaveDocument)){
			super.getRequestResult().setRsltCode("0");
			super.getRequestResult().setMessage("修改会议方案成功");
			ActionContext.getContext().getSession().put("_lastOpResult", super.getRequestResult());
		}
		if("task".equals(this.getFromFlag())){
			return "TASK";
		}
		return SUCCESS;
	}

	public SchemeJobDataDTO getSchemeJobDataDTO() {
		return schemeJobDataDTO;
	}

	public void setSchemeJobDataDTO(SchemeJobDataDTO schemeJobDataDTO) {
		this.schemeJobDataDTO = schemeJobDataDTO;
	}

	public void setAutoSaveDocument(String autoSaveDocument) {
		this.autoSaveDocument = autoSaveDocument;
	}

	public String getAutoSaveDocument() {
		return autoSaveDocument;
	}
}
